textview: Perform tougher handle visibility checks after hiding the popover
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 12 Jun 2015 10:45:03 +0000 (12:45 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 12 Jun 2015 10:45:03 +0000 (12:45 +0200)
The handles might fall outside the visible area, and shouldn't be shown
then. Just call gtk_text_view_update_handles() which will perform these
checks, and keep the handle conveniently hidden.

This was leading to unexpectedly visible handles (and in the
wrong/previous position, the handle code doesn't relocate the widget
it's about to hide) when "select all" was selected in the popover on
a textview needing scrollbars.
and extending the selection beyond the view above and/or below.

gtk/gtktextview.c

index 7edb925e645800f4bf7620a03852ac329a2346e7..29d0648ba8266aeef0b5f83a06be24a0fcc1f027 100644 (file)
@@ -9202,14 +9202,12 @@ show_or_hide_handles (GtkWidget   *popover,
   handle = text_view->priv->text_handle;
   mode = _gtk_text_handle_get_mode (handle);
 
-  if (mode == GTK_TEXT_HANDLE_MODE_CURSOR)
-    {
-      _gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_CURSOR, !visible);
-    }
-  else if (mode == GTK_TEXT_HANDLE_MODE_SELECTION)
+  if (!visible)
+    gtk_text_view_update_handles (text_view, mode);
+  else
     {
-      _gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_START, !visible);
-      _gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_END, !visible);
+      _gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_START, FALSE);
+      _gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_END, FALSE);
     }
 }